package com.wxlsoft.excel.extract;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

import javax.swing.JProgressBar;

import com.wxlsoft.excel.core.AbstractProcessor;
import com.wxlsoft.excel.core.RunHandler;

public class ExtractHandler extends RunHandler {

	public ExtractHandler(JProgressBar progressBar1, String filePath) {
		super(create(filePath), progressBar1, filePath);
	}

	private static AbstractProcessor create(String filePath) {
		Path fromPath = new File(filePath).toPath();
		Path to = Paths.get(fromPath.getParent().toString(), fromPath.getFileName().toString().replaceAll("(.*)\\.(.*)$", "$1_%s.xlsx"));
		
		return new InterfaceManifestProcessor(fromPath.toString(), to.toString());
	}

	public void run() {
		processor.execute();
	}

}
